package cn.edu.njpi;

import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.*;
import javafx.scene.paint.Paint;
import javafx.scene.text.Font;
import javafx.stage.Stage;

/**
 * @author 朱宗辉
 * @version V1.0
 * @Package cn.edu.njpi
 * @date 2022/5/11 8:18 PM
 */
public class Main extends Application {
    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage stage) throws Exception {
        Button b1 = new Button();
        b1.setText("这是按钮");
        b1.setLayoutY(100);
        b1.setLayoutX(100);
        b1.setPrefWidth(400);
        b1.setPrefHeight(200);
        b1.setFont(Font.font("宋体", 40));
        b1.setTextFill(Paint.valueOf("#14657D"));
        BackgroundFill backgroundFill = new BackgroundFill(Paint.valueOf("#8457FF"), new CornerRadii(20), new Insets(10));
        Background background = new Background(backgroundFill);
        b1.setBackground(background);
        BorderStroke borderStroke = new BorderStroke(Paint.valueOf("#2367F2"), BorderStrokeStyle.SOLID, new CornerRadii(20), new BorderWidths(10));
        Border border = new Border(borderStroke);
        b1.setBorder(border);
        b1.setStyle("-fx-background-color: red;" +
                "-fx-background-radius: 20;" +
                "-fx-text-fill: green");
        b1.setOnAction(actionEvent -> {
            Button button = (Button) actionEvent.getSource();
            System.out.println("单击" + button.getText());
        });
        Group root = new Group();
        root.getChildren().add(b1);
        Scene scene = new Scene(root);
        stage.setScene(scene);
        stage.setTitle("javafx");
        stage.setHeight(800);
        stage.setWidth(800);
        stage.show();
    }
}
